import requests,json
from AipSpeech import param_config as paramConfig
from aip import AipSpeech

# class aip_speech_client:
#
#     # 获取token
#     @staticmethod
#     def getToken():
#         resultStr = paramConfig.OAUTH.format(paramConfig.API_KEY, paramConfig.SECRET_KEY)
#         tokenStr = requests.get(resultStr)
#         if(tokenStr.status_code == 200):
#             return json.loads(tokenStr.text)
#         else:
#             return
#
#
#     # 获取百度接口客户端
#     @staticmethod
#     def get_baidu_client():
#         return AipSpeech(paramConfig.APP_ID, paramConfig.API_KEY, paramConfig.SECRET_KEY)


def getToken():
    resultStr = paramConfig.OAUTH.format(paramConfig.API_KEY, paramConfig.SECRET_KEY)
    tokenStr = requests.get(resultStr)
    if(tokenStr.status_code == 200):
        return json.loads(tokenStr.text)
    else:
        return


# 获取百度接口客户端
def get_baidu_client():
    return AipSpeech(paramConfig.APP_ID, paramConfig.API_KEY, paramConfig.SECRET_KEY)